package com.learning.platform.repository;

import com.learning.platform.entity.Comment;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommentRepository extends JpaRepository<Comment, Long> {
    
    Page<Comment> findByPostIdAndParentIdIsNull(Long postId, Pageable pageable);
    
    List<Comment> findByParentIdOrderByCreatedAtAsc(Long parentId);
    
    List<Comment> findByPostId(Long postId);
    
    long countByPostId(Long postId);
    
    long countByUserId(Long userId);
}

